/*
 * @Author: DUST
 * @Date: 2023-06-25 14:33:17
 * @LastEditors: DUST
 * @LastEditTime: 2023-06-25 14:37:23
 * @FilePath: \national-standard-platform-alarm-screen\src\utils\ckThree\cleanObj.js
 * @Description: 
 * undefined
 */
export const clearGroup = (group) => {
  const clearCache = (item) => {
    item.geometry.dispose();
    if(Object.prototype.toString.call(item.material) == "[object Array]") {
      item.material.forEach(element => {
        element.dispose();
      });
    }
    else item.material.dispose();
    // item.material.dispose();
  };
  const removeObj = (obj) => {
    let arr = obj.children.filter((x) =>!! x);
    arr.forEach((item) => {
      if (item.children.length) {
        removeObj(item);
      } else {
        clearCache(item);
        item.clear();
      }
    });
    obj.clear();
    arr = null;
  };
  removeObj(group);
}
